﻿@{
    var authorizer = new Authorizer();
    string[] subMenu_check = TempData.Get<string[]>("subMenu-check", new string[0]);
    var navigationService = DIContainer.Resolve<NavigationService>();
    var navigations = navigationService.GetAll();
    HttpCookie strcookie = System.Web.HttpContext.Current.Request.Cookies.Get("sideSwitch");
    var strcookievals = false;
    if (strcookie != null && strcookie.Value == "1")
    {
        strcookievals = true;
    }

    Func<string, bool> subMenucheck = (n) =>
    {
        if (subMenu_check.Length > 0)
        {
            if (new List<string>(subMenu_check).Contains(n) && strcookievals == false)
            {
                return true;
            }
        }
        return false;
    };

    var askconfig = ApplicationConfig.GetConfig("Ask");
    bool showAskNav = askconfig != null ? askconfig.IsEnabled : false;
    var documentconfig = ApplicationConfig.GetConfig("Document");
    bool showDocNav = documentconfig != null ? documentconfig.IsEnabled : false;
    var eventconfig = ApplicationConfig.GetConfig("Event");
    bool showEventNav = eventconfig != null ? eventconfig.IsEnabled : false;
    //var pointMallConfig = ApplicationConfig.GetConfig("PointMall");
    //bool showPointMall = pointMallConfig != null ? pointMallConfig.IsEnabled : false;
}
<nav class="navbar-default tn-global-nav" id="navbar-default">
    <div class="tn-nav-header">
        <a class="tn-nav-brand" href="@SiteUrls.Instance().ControlPanelHome()">
            近乎管理后台
        </a>
    </div>
    <ul class="nav tn-first-level dropdowns">
        <li>
            <a href="JavaScript:;" class="@(subMenucheck("CMS")?"active":"")">
                <i class="fa fa-file-text"></i>
                <span class="tn-text">资讯</span>
                <i class="fa fa-angle-right tn-arrow"></i>
            </a>
            <ul class="nav tn-second-level" @if (subMenucheck("CMS")) { <text> style="display: block;" </text>   }>
                <li>
                    <a class="@(subMenucheck("ManageCMS")?"active":"")" href="@SiteUrls.Instance().ManageCMS()">
                        <span class="tn-text">资讯管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageContentCategories")?"active":"")" href="@SiteUrls.Instance().ManageContentCategories()">
                        <span class="tn-text">栏目管理</span>
                    </a>
                </li>
            </ul>
        </li>
        <li>
            <a class="@(subMenucheck("Sections")?"active":"")" href="JavaScript:;">
                <i class="fa fa-comments"></i>
                <span class="tn-text">贴吧</span>
                <i class="fa fa-angle-right tn-arrow"></i>
            </a>
            <ul class="nav tn-second-level" @if (subMenucheck("Sections")) { <text> style="display: block;" </text>   }>
                <li>
                    <a class="@(subMenucheck("ManageThreads")?"active":"")" href="@SiteUrls.Instance().ManageThreads()">
                        <span class="tn-text">贴子管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageSections")?"active":"")" href="@SiteUrls.Instance().ManageSections()">
                        <span class="tn-text">贴吧管理</span>
                    </a>
                </li>
            </ul>
        </li>
        @if (showAskNav)
        {
            <li>
                <a class="@(subMenucheck("Ask")?"active":"")" href="JavaScript:;">
                    <i class="fa fa-asl-interpreting "></i>
                    <span class="tn-text">问答</span>
                    <i class="fa fa-angle-right tn-arrow"></i>
                </a>
                <ul class="nav tn-second-level" @if (subMenucheck("Ask")) { <text> style="display: block;" </text>   }>
                    <li>
                        <a class="@(subMenucheck("ManageQuestions") ?"active":"")" href="@CachedUrlHelper.Action("ManageQuestions", "ControlPanelAsk","ConsoleViews" )">
                            <span class="tn-text">问题管理</span>
                        </a>
                    </li>
                    <li>
                        <a class="@(subMenucheck("ManageAnswers") ?"active":"")" href="@CachedUrlHelper.Action("ManageAnswers", "ControlPanelAsk","ConsoleViews" )">
                            <span class="tn-text">回答管理</span>
                        </a>
                    </li>
                </ul>
            </li>
        }
        @if (showDocNav)
        {
            <li>
                <a class="@(subMenucheck("Document")?"active":"")" href="@CachedUrlHelper.Action("ManageDocument", "ControlPanelDocument","ConsoleViews" )">
                    <i class="fa fa-book"></i>
                    <span class="tn-text">文库</span>

                </a>

            </li>
        }
        @if (showEventNav&& navigations.Where(n=>n.NavigationUrl.ToLower().IndexOf("event")>0).Count()>0)
        {
            <li>
                <a class="@(subMenucheck("Event")?"active":"")" href="@CachedUrlHelper.Action("ManageEvent", "ControlPanelEvent","ConsoleViews" )">
                    <i class="fa fa-futbol-o"></i>
                    <span class="tn-text">活动</span>
                </a>
            </li>
        }
      @if (Utility.CheckApplication("Vote") && navigations.Where(n => n.NavigationUrl.ToLower().IndexOf("vote") > 0).Count() > 0)
      {
            <li>
                <a class="@(subMenucheck("Vote")?"active":"")" href="@CachedUrlHelper.Action("ManageVote", "ControlPanelVote","ConsoleViews" )">
                    <i class="fa fa-bar-chart"></i>
                    <span class="tn-text">投票</span>

                </a>

            </li>
        }
        @if (Utility.CheckApplication("PointMall"))
        {
            <li>
                <a class="@(subMenucheck("PointMall")?"active":"")" href="JavaScript:;">
                    <i class="fa fa-database "></i>
                    <span class="tn-text">积分商城</span>
                    <i class="fa fa-angle-right tn-arrow"></i>
                </a>
                <ul class="nav tn-second-level" @if (subMenucheck("PointMall")) { <text> style="display: block;" </text>    }>
                    <li>
                        <a class="@(subMenucheck("ManagePointMallProducts") ?"active":"")" href="@CachedUrlHelper.Action("ManagePointMallProducts", "ControlPanelPointMall","ConsoleViews" )">
                            <span class="tn-text">礼品管理</span>
                        </a>
                    </li>
                    <li>
                        <a class="@(subMenucheck("ManagePointMallOrders") ?"active":"")" href="@CachedUrlHelper.Action("ManagePointMallOrders", "ControlPanelPointMall","ConsoleViews" )">
                            <span class="tn-text">兑换订单</span>
                        </a>
                    </li>
                </ul>
            </li>
        }
        <li>

            <a class="@(subMenucheck("Public")?"active":"")" href="JavaScript:;">
                <i class="fa fa-navicon"></i>
                <span class="tn-text">公共内容</span>
                <i class="fa fa-angle-right tn-arrow"></i>
            </a>
            <ul class="nav tn-second-level" @if (subMenucheck("Public")) { <text> style="display: block;" </text>             }>
                <li>
                    <a class="@(subMenucheck("ManageContentItems")?"active":"")" href="@SiteUrls.Instance().ManageContentItems()">
                        <span class="tn-text">内容推荐</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageComments")?"active":"")" href="@SiteUrls.Instance().ManageComments()">
                        <span class="tn-text">评论管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageCategories")?"active":"")" href="@SiteUrls.Instance().ManageCategories()">
                        <span class="tn-text">类别管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageTags")?"active":"")" href="@SiteUrls.Instance().ManageTags()">
                        <span class="tn-text">标签管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageLinks")?"active":"")" href="@SiteUrls.Instance().ManageLinks()">
                        <span class="tn-text">链接管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageAdvertising")?"active":"")" href="@SiteUrls.Instance().ManageAdvertising(null)">
                        <span class="tn-text">广告管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageUserImpeachReport")?"active":"")" href="@SiteUrls.Instance().ManageUserImpeachReport()">
                        <span class="tn-text">举报管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageSearchWords")?"active":"")" href="@SiteUrls.Instance().ManageSearchWords()">
                        <span class="tn-text">搜索热词</span>
                    </a>
                </li>
            </ul>
        </li>
        <li>
            <a class="@(subMenucheck("User")?"active":"")" href="JavaScript:;">
                <i class="fa fa-user"></i>
                <span class="tn-text">用户</span>
                <i class="fa fa-angle-right tn-arrow"></i>
            </a>
            <ul class="nav tn-second-level" @if (subMenucheck("User")) { <text> style="display: block;" </text>             }>
                <li>
                    <a class="@(subMenucheck("ManageUser")?"active":"")" href="@SiteUrls.Instance().ManageUser()">
                        <span class="tn-text">用户管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageUserSignIn")?"active":"")" href="@SiteUrls.Instance().ManageUserSignIn()">
                        <span class="tn-text">用户签到</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageRoles")?"active":"")" href="@SiteUrls.Instance().ManageRoles()">
                        <span class="tn-text">角色管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageUserRanks")?"active":"")" href="@SiteUrls.Instance().ManageUserRanks()">
                        <span class="tn-text">等级管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageUserMedals")?"active":"")" href="@SiteUrls.Instance().ManageUserMedals()">
                        <span class="tn-text">勋章管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManagePointTasks")?"active":"")" href="@SiteUrls.Instance().ManagePointTasks()">
                        <span class="tn-text">积分任务</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManagePermissions")?"active":"")" href="@SiteUrls.Instance().ManagePermissions()">
                        <span class="tn-text">权限管理</span>
                    </a>
                </li>



                <li>
                    <a class="@(subMenucheck("Managepointrecords")?"active":"")" href="@SiteUrls.Instance().Managepointrecords()">
                        <span class="tn-text">积分记录</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManagePointRechargeOrder")?"active":"")" href="@SiteUrls.Instance().ManagePointRechargeOrder()">
                        <span class="tn-text">积分充值</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageOperationLogs")?"active":"")" href="@SiteUrls.Instance().ManageOperationLogs()">
                        <span class="tn-text">操作日志</span>
                    </a>
                </li>
            </ul>
        </li>
        <li>
            <a class="@(subMenucheck("Setting")?"active":"")" href="JavaScript:;">
                <i class="fa fa-gears"></i>
                <span class="tn-text">设置</span>
                <i class="fa fa-angle-right tn-arrow"></i>
            </a>
            <ul class="nav tn-second-level" @if (subMenucheck("Setting")) { <text> style="display: block;" </text>             }>
                <li>
                    <a class="@(subMenucheck("ManageSiteSettings")?"active":"")" href="@SiteUrls.Instance().ManageSiteSettings()">
                        <span class="tn-text">站点设置</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageNavigations")?"active":"")" href="@SiteUrls.Instance().ManageNavigations()">
                        <span class="tn-text">导航管理</span>
                    </a>
                </li>
                @if (Utility.CheckThirdPartyLogin())
                {
                    <li>
                        <a class="@(subMenucheck("ManageThirdLogin")?"active":"")" href="@SiteUrls.Instance().ManageThirdLogin()">
                            <span class="tn-text">第三方登录</span>
                        </a>
                    </li>
                }
                <li>
                    <a class="@(subMenucheck("Managepointrules")?"active":"")" href="@SiteUrls.Instance().Managepointrules()">
                        <span class="tn-text">积分规则</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageAudits")?"active":"")" href="@SiteUrls.Instance().ManageAudits()">
                        <span class="tn-text">审核规则</span>
                    </a>
                </li>

            </ul>
        </li>
        <li>
            <a class="@(subMenucheck("Tool")?"active":"")" href="JavaScript:;">
                <i class="fa fa-wrench"></i>
                <span class="tn-text">工具</span>
                <i class="fa fa-angle-right tn-arrow"></i>
            </a>
            <ul class="nav tn-second-level" @if (subMenucheck("Tool")) { <text> style="display: block;" </text>       }>
                <li>
                    <a class="@(subMenucheck("ManageSearchIndexs")?"active":"")" href="@SiteUrls.Instance().ManageSearchIndexs()">
                        <span class="tn-text">索引管理</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("ManageaTasks")?"active":"")" href="@SiteUrls.Instance().ManageTasks()">
                        <span class="tn-text">任务管理</span>
                    </a>
                </li>
                <li>
                    <a id="clearCache" href="JavaScript:;">
                        <span class="tn-text">清除缓存</span>
                    </a>
                </li>
                <li>
                    <a id="restartSite" href="JavaScript:;">
                        <span class="tn-text">重启站点</span>
                    </a>
                </li>
                <li>
                    <a class="@(subMenucheck("PauseSiteSettings")?"active":"")" href="@SiteUrls.Instance().PauseSiteSettings()">
                        <span class="tn-text">暂停站点</span>
                    </a>
                </li>
            </ul>
        </li>

    </ul>
    <div class="tn-side-switch text-right">
        <div class="tn-side-powered">Powered by<a target="_blank" href="http://www.jinhusns.com/">近乎</a>v5.2</div>
        <a id="sideSwitch" href="JavaScript:;"><i class="fa fa-chevron-circle-left"></i></a>
    </div>
</nav>
<script>
    require(['jquery'], function ($) {

        function sleep(d) {
            for (var t = Date.now() ; Date.now() - t <= d;);
        }


        $("#restartSite").click(function myfunction() {

            layer.confirm("你确定要重启站点吗？", {
                btn: ['确认', '取消'],//按钮
                scrollbar: false
            }, function () {
                layer.closeAll();
                var index = layer.load();
                $.ajax({
                    type: "POST",
                    url: "@SiteUrls.Instance().UnloadAppDomain()",
                    async: true,
                    success: function myfunction(data) {
                        setTimeout(function () {

                            layer.close(index);
                            if (data) {
                                layer.msg("重启成功", {
                                    icon: 1
                                });
                            }
                            else {
                                layer.msg("无权操作", {
                                    icon: 2
                                });
                            }
                        }, 3000)

                    }
                });
            });
        });
        $("#clearCache").click(function myfunction() {

            layer.confirm("你确定要清除缓存吗？", {
                btn: ['确认', '取消'],//按钮
                scrollbar: false
            }, function () {
                layer.closeAll();
                var index = layer.load();
                $.ajax({
                    type: "POST",
                    url: "@SiteUrls.Instance().ResetCache()",
                    async: true,
                    success: function myfunction(data) {
                        setTimeout(function () {

                            layer.close(index);
                            if (data) {
                                layer.msg("清除成功", {
                                    icon: 1
                                });
                            }
                            else {
                                layer.msg("无权操作", {
                                    icon: 2
                                });
                            }
                        }, 3000)

                    }
                });

            });
        });
    })

</script>
